/*
 * TimeShift.h
 *
 *  Created on: 2020年6月19日
 *      Author: chuanjiang.zh
 */

#ifndef TIMESHIFT_H_
#define TIMESHIFT_H_

#include "BasicType.h"

class DLLEXPORT TimeShift
{
public:
	enum Status
	{
		STATUS_NORMAL = 0,
		STATUS_LEAP = 1,
		STATUS_BACKWARD = 2,
		STATUS_INVALID = 3
	};

public:
	TimeShift();
	virtual ~TimeShift();

	void reset();

	int64_t shift(int64_t ts, int64_t& duration, int* status = nullptr);

	void setFrameDuration(int64_t duration);

	void setFrameGap(int count);

	void enableTune(bool enabled);

protected:
	int64_t	m_frameDuration;
	int		m_frameGap;
	int64_t	m_gapDuration;

	int64_t m_rawTs;
	int64_t m_prevOutTs;

	bool	m_tuneEnabled;

};

#endif /* TIMESHIFT_H_ */
